import Vue from 'vue'
import VueRouter from 'vue-router'
/**
 *  加载模块
 */
Vue.use(VueRouter)
    /**
     *  路由配置
     * {
            name: 'home',
            path: '/',
            redirect: '/home',
            meta: { title: '主页' },
            component: resolve => require(['../pages/home.vue'], resolve)
        }
     */
const router = new VueRouter({
    base: __dirname,
    likActiveClass: 'link-active',
    routes: [{
            path: '/',
            redirect: '/home',
        }, {
            path: '/',
            name: 'init',
            component: resolve => require(['../pages/init.vue'], resolve),
            children: [{
                    path: 'personal/userInfo',
                    name: 'userInfo',
                    component: resolve => require(['../pages/personal/userInfo.vue'], resolve),
                    meta: { title: '我的' }
                },
                {
                    path: '/home',
                    name: 'home',
                    component: resolve => require(['../pages/home.vue'], resolve),
                    meta: { title: '主页' }
                },
                {
                    path: 'cart/cart',
                    name: 'cart',
                    component: resolve => require(['../pages/cart/cart.vue'], resolve),
                    meta: { title: '购物车' }
                },
                {
                    path: 'find/find',
                    name: 'find',
                    component: resolve => require(['../pages/find/find.vue'], resolve),
                    meta: { title: '发现' }
                },
                {
                    path: 'classify/classify',
                    name: 'classify',
                    component: resolve => require(['../pages/classify/classify.vue'], resolve),
                    meta: { title: '分类' }
                }
            ]
        },
        {
            path: 'classify/goSearch',
            name: 'goSearch',
            component: resolve => require(['../pages/classify/goSearch.vue'], resolve),
            meta: { title: '搜索' }
        }, {
            path: 'classify/goSearch1',
            name: 'goSearch1',
            component: resolve => require(['../pages/classify/goSearch1.vue'], resolve),
            meta: { title: '搜索' }
        }, {
            path: 'goods/secondKillList',
            name: 'secondKillList',
            component: resolve => require(['../pages/goods/secondKillList.vue'], resolve),
            meta: { title: '秒杀列表' }
        },

        {
            path: '/login',
            name: 'login',
            component: resolve => require(['../pages/login.vue'], resolve),
            meta: { title: '登录' }
        },

        {
            path: '/goods/goods_detail',
            name: 'goods_detail',
            component: resolve => require(['../pages/goods/goods_detail.vue'], resolve),
            meta: { title: '商品详情' }
        },
        {
            path: '/goods/order_confirm',
            name: 'order_confirm',
            component: resolve => require(['../pages/goods/order_confirm.vue'], resolve),
            meta: {},
            // beforeRouteLeave : (to, from, next) => {
            //     this.$destroy()
            //   }
        },
        {
            path: '/goods/pay_money',
            name: 'pay_money',
            component: resolve => require(['../pages/goods/pay_money.vue'], resolve),
            meta: { title: '订单支付' }
        },
        {
            path: '/goods/goods_address',
            name: 'goods_address',
            component: resolve => require(['../pages/goods/goods_address.vue'], resolve),
            meta: { title: '收货地址' }
        },
        {
            path: '/goods/add_address',
            name: 'add_address',
            component: resolve => require(['../pages/goods/add_address.vue'], resolve),
            meta: { title: '新建地址' }
        },
        {
            path: '/personal/vip_manage',
            name: 'vip_manage',
            component: resolve => require(['../pages/personal/vip_manage.vue'], resolve),
            meta: { title: '会员管理' }
        },
        {
            path: '/personal/myCollection',
            name: 'myCollection',
            component: resolve => require(['../pages/personal/myCollection.vue'], resolve),
            meta: { title: '我的收藏' }
        },
        {
            path: '/personal/myRecommend',
            name: 'myRecommend',
            component: resolve => require(['../pages/personal/myRecommend.vue'], resolve),
            meta: { title: '我的推荐' }
        },
        {
            path: '/personal/myHistory',
            name: 'myHistory',
            component: resolve => require(['../pages/personal/myHistory.vue'], resolve),
            meta: { title: '浏览记录' }
        },
        {
            path: '/personal/myFocus',
            name: 'myFocus',
            component: resolve => require(['../pages/personal/myFocus.vue'], resolve),
            meta: { title: '我的关注' }
        },
        {
            path: '/personal/myBuyHistory',
            name: 'myBuyHistory',
            component: resolve => require(['../pages/personal/myBuyHistory.vue'], resolve),
            meta: { title: '消费记录' }
        },
        {
            path: '/personal/logisticsQuery',
            name: 'logisticsQuery',
            component: resolve => require(['../pages/personal/logisticsQuery.vue'], resolve),
            meta: { title: '物流查询' }
        },
        {
            path: '/personal/myCoder',
            name: 'myCoder',
            component: resolve => require(['../pages/personal/myCoder.vue'], resolve),
            meta: { title: '我的二维码' }
        },
        {
            path: '/personal/myInvoice',
            name: 'myInvoice',
            component: resolve => require(['../pages/personal/myInvoice.vue'], resolve),
            meta: { title: '我的发票' }
        },
        {
            path: '/personal/myeval',
            name: 'myeval',
            component: resolve => require(['../pages/personal/myeval.vue'], resolve),
            meta: { title: '我的评价' }
        },
        {
            path: '/personal/redPackets',
            name: 'redPackets',
            component: resolve => require(['../pages/personal/redPackets.vue'], resolve),
            meta: { title: '红包' }
        },
        {
            path: '/personal/myShare',
            name: 'myShare',
            component: resolve => require(['../pages/personal/myShare.vue'], resolve),
            meta: { title: '分享' }
        },
        {
            path: '/personal/my_order',
            name: 'my_order',
            component: resolve => require(['../pages/personal/my_order.vue'], resolve),
            meta: { title: '订单' }
        },
        {
            path: '/personal/backMoney',
            name: 'backMoney',
            component: resolve => require(['../pages/personal/backMoney.vue'], resolve),
            meta: { title: '返利' }
        },
        {
            path: '/personal/qianbao',
            name: 'qianbao',
            component: resolve => require(['../pages/personal/qianbao.vue'], resolve),
            meta: { title: '钱包' }
        },
        {
            path: '/personal/liuyan',
            name: 'liuyan',
            component: resolve => require(['../pages/personal/liuyan.vue'], resolve),
            meta: { title: '留言' }
        },
        {
            path: '/personal/jifenExchange',
            name: 'jifenExchange',
            component: resolve => require(['../pages/personal/jifenExchange.vue'], resolve),
            meta: { title: '积分商城' }
        }, {
            path: '/personal/mySigned',
            name: 'mySigned',
            component: resolve => require(['../pages/personal/mySigned.vue'], resolve),
            meta: { title: '每日签到' }
        }, {
            path: '/personal/myJiFen',
            name: 'myJiFen',
            component: resolve => require(['../pages/personal/myJiFen.vue'], resolve),
            meta: { title: '我的积分' }
        },
        {
            path: '/personal/pingjia',
            name: 'pingjia',
            component: resolve => require(['../pages/personal/pingjia.vue'], resolve),
            meta: { title: '评价' }
        },


    ]
})

/**
 *  路由出口
 */
export default router